var casper = require('casper').create({   
    verbose: true, 
    logLevel: 'debug',
    pageSettings: {
         loadImages:  false,        
         loadPlugins: true,         
         userAgent: 'Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0'
    }
});

casper.start('http://class.hujiang.com/');

casper.then(function(){
        this.thenEvaluate(function() {
            $('#headerBarLogin').click();
            $('input[name="username"]').attr('value','你的用户名');
            $('input[name="password"]').attr('value','你的密码');
            $('button.hp-btn.hp-btn-green')[0].click();
            $('div.hp-close').click();
        });
        
        this.wait(1000,function(){
            casper.thenOpen('http://my.hujiang.com/pc/7052382/home', function() {
                this.wait(1000,function(){
                    if(this.exists('div.button.signed')){
                        this.echo('你已经打卡啦...');
                        return;
                    }
                    
                    this.thenEvaluate(function() {
                        $('div.button.unsigned').click();
                        //button unsigned
                    });
                    this.echo('滴滴滴，老司机打卡成功...');
                    
                });
            });
        });
    
});

casper.run();